home *** CD-ROM | disk | FTP | other *** search
/ Champak 86 / (Vol 86) My Disc.iso / Games / pet_1112.swf / scripts / __Packages / EZClick2Drag.as next >
Text File  |  2009-04-14  |  2KB  |  62 lines

  1. class EZClick2Drag extends MovieClip
  2. {
  3.    static var RELEASE_DELAY = 500;
  4.    static var DRAGGING = false;
  5.    var dragging = false;
  6.    function EZClick2Drag()
  7.    {
  8.       super();
  9.       if(!this._parent.ezClick2Drags)
  10.       {
  11.          this._parent.ezClick2Drags = new Array();
  12.       }
  13.       this._parent.ezClick2Drags.push(this);
  14.       this.targets = new Array();
  15.       this.targetActions = new Array();
  16.       this.onPress = this.press;
  17.    }
  18.    function press()
  19.    {
  20.       this.onDragStart(this);
  21.       EZClick2Drag.DRAGGING = true;
  22.       this.dragging = true;
  23.       this.swapDepths(this._parent.getNextHighestDepth());
  24.       this.startDrag(false);
  25.       this.onMouseDown = this.drop;
  26.       delete this.onPress;
  27.    }
  28.    function initMouseUp()
  29.    {
  30.       if(this.dragging)
  31.       {
  32.          this.onMouseUp = this.drop;
  33.       }
  34.    }
  35.    function resetOnPress()
  36.    {
  37.       this.onPress = this.press;
  38.    }
  39.    function drop()
  40.    {
  41.       delete this.onMouseDown;
  42.       delete this.onMouseUp;
  43.       _global.setTimeout(this,"resetOnPress",10);
  44.       EZClick2Drag.DRAGGING = false;
  45.       this.dragging = false;
  46.       this.stopDrag();
  47.       var _loc3_ = false;
  48.       for(var _loc4_ in this.targets)
  49.       {
  50.          if(typeof this.targets[_loc4_] == "movieclip" && this.hitTest(this.targets[_loc4_]) || typeof this.targets[_loc4_] == "object" && this.hitTest(this.targets[_loc4_]._x,this.targets[_loc4_]._y,false))
  51.          {
  52.             this.targetActions._loc4_(this);
  53.             _loc3_ = true;
  54.          }
  55.       }
  56.       if(!_loc3_)
  57.       {
  58.          this.missedTargetsAction(this);
  59.       }
  60.    }
  61. }
  62.